home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / pdftops / xpdf / h / Gfx < prev    next >
Text File  |  1996-06-09  |  7KB  |  260 lines

  1. //========================================================================
  2. //
  3. // Gfx.h
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8.  
  9. #ifndef GFX_H
  10. #define GFX_H
  11.  
  12. #ifdef __GNUC__
  13. //#pragma interface
  14. #endif
  15.  
  16. #include "gtypes.h"
  17.  
  18. class GString;
  19. class Array;
  20. class Stream;
  21. class Parser;
  22. class Dict;
  23. class OutputDev;
  24. class PSOutput;
  25. class GfxFontDict;
  26. class GfxState;
  27. class Gfx;
  28.  
  29. //------------------------------------------------------------------------
  30. // Gfx
  31. //------------------------------------------------------------------------
  32.  
  33. enum TchkType {
  34.   tchkBool,
  35.   tchkInt,
  36.   tchkNum,
  37.   tchkString,
  38.   tchkName,
  39.   tchkArray,
  40.   tchkNone            // used to avoid empty initializer lists
  41. };
  42.  
  43. enum GfxClipType {
  44.   clipNone,
  45.   clipNormal,
  46.   clipEO
  47. };
  48.  
  49. #define maxArgs 8
  50.  
  51. struct Operator {
  52.   char name[4];
  53.   int numArgs;
  54.   TchkType tchk[maxArgs];
  55.   void (Gfx::*func)(Object args[]);
  56.   void (Gfx::*psFunc)(Object args[]);
  57. };
  58.  
  59. class Gfx {
  60. public:
  61.  
  62.   // Constructor for regular output.
  63.   Gfx(OutputDev *out1, Dict *fontDict, Dict *xObjDict1,
  64.       int dpi, int x1, int y1, int x2, int y2, int rotate);
  65.  
  66.   // Constructor for PostScript output.
  67.   Gfx(PSOutput *psOut1, Dict *fontDict, Dict *xObjDict1,
  68.       int dpi, int x1, int y1, int x2, int y2, int rotate);
  69.  
  70.   // Destructor.
  71.   ~Gfx();
  72.  
  73.   // Interpret an array or stream.
  74.   void display(Array *a1);
  75.   void display(Stream *str1);
  76.  
  77. private:
  78.  
  79.   OutputDev *out;        // output device
  80.   PSOutput *psOut;        // PostScript output file
  81.   GfxFontDict *fonts;        // font dictionary
  82.   Dict *xObjDict;        // XObject dictionary
  83.  
  84.   GfxState *state;        // current graphics state
  85.   GBool fontChanged;        // set if font or text matrix has changed
  86.   GfxClipType clip;        // do a clip?
  87.  
  88.   GString *psFont;        // font (for PS output)
  89.   double psFontSize;        // font size (for PS output)
  90.   GfxFont *psGfxFont;        // font info (for PS output)
  91.  
  92.   Array *a;            // if displaying from an array
  93.   int index;            // index in array
  94.   Parser *parser;        // if displaying from a stream
  95.  
  96. #ifdef __riscos
  97.   // snb94r@ecs.soton.ac.uk added this for the dynamic operator table
  98.   // initialisation.  opTab is new[]'ed at that time
  99.   static Operator *opTab;    // table of operators (chg to ptr, snb)
  100.   void add_Gfx_op(const char *, int, void (Gfx::*)(Object []),
  101.       void (Gfx::*)(Object []), ...);
  102.   void init_opTab();        // initialise the table (snb)
  103. #else
  104.   static Operator opTab[];    // table of operators
  105. #endif
  106.  
  107.   void go();
  108.   void execOp(Object *cmd, Object args[], int numArgs);
  109.   Operator *findOp(char *name);
  110.   GBool checkArg(Object *arg, TchkType type);
  111.   Object *nextObj(Object *obj);
  112.   void done();
  113.  
  114.   // graphics state operators
  115.   void opSave(Object args[]);
  116.   void psSave(Object args[]);
  117.   void opRestore(Object args[]);
  118.   void psRestore(Object args[]);
  119.   void opConcat(Object args[]);
  120.   void psConcat(Object args[]);
  121.   void opSetDash(Object args[]);
  122.   void psSetDash(Object args[]);
  123.   void opSetFlat(Object args[]);
  124.   void psSetFlat(Object args[]);
  125.   void opSetLineJoin(Object args[]);
  126.   void psSetLineJoin(Object args[]);
  127.   void opSetLineCap(Object args[]);
  128.   void psSetLineCap(Object args[]);
  129.   void opSetMiterLimit(Object args[]);
  130.   void psSetMiterLimit(Object args[]);
  131.   void opSetLineWidth(Object args[]);
  132.   void psSetLineWidth(Object args[]);
  133.  
  134.   // color operators
  135.   void opSetFillGray(Object args[]);
  136.   void psSetFillGray(Object args[]);
  137.   void opSetStrokeGray(Object args[]);
  138.   void psSetStrokeGray(Object args[]);
  139.   void opSetFillCMYKColor(Object args[]);
  140.   void psSetFillCMYKColor(Object args[]);
  141.   void opSetStrokeCMYKColor(Object args[]);
  142.   void psSetStrokeCMYKColor(Object args[]);
  143.   void opSetFillRGBColor(Object args[]);
  144.   void psSetFillRGBColor(Object args[]);
  145.   void opSetStrokeRGBColor(Object args[]);
  146.   void psSetStrokeRGBColor(Object args[]);
  147.  
  148.   // path segment operators
  149.   void opMoveTo(Object args[]);
  150.   void psMoveTo(Object args[]);
  151.   void opLineTo(Object args[]);
  152.   void psLineTo(Object args[]);
  153.   void opCurveTo(Object args[]);
  154.   void psCurveTo(Object args[]);
  155.   void opCurveTo1(Object args[]);
  156.   void psCurveTo1(Object args[]);
  157.   void opCurveTo2(Object args[]);
  158.   void psCurveTo2(Object args[]);
  159.   void opRectangle(Object args[]);
  160.   void psRectangle(Object args[]);
  161.   void opClosePath(Object args[]);
  162.   void psClosePath(Object args[]);
  163.  
  164.   // path painting operators
  165.   void opEndPath(Object args[]);
  166.   void psEndPath(Object args[]);
  167.   void opStroke(Object args[]);
  168.   void psStroke(Object args[]);
  169.   void opCloseStroke(Object args[]);
  170.   void psCloseStroke(Object args[]);
  171.   void opFill(Object args[]);
  172.   void psFill(Object args[]);
  173.   void opEOFill(Object args[]);
  174.   void psEOFill(Object args[]);
  175.   void opFillStroke(Object args[]);
  176.   void psFillStroke(Object args[]);
  177.   void opCloseFillStroke(Object args[]);
  178.   void psCloseFillStroke(Object args[]);
  179.   void opEOFillStroke(Object args[]);
  180.   void psEOFillStroke(Object args[]);
  181.   void opCloseEOFillStroke(Object args[]);
  182.   void psCloseEOFillStroke(Object args[]);
  183.   void doEndPath();
  184.   void psDoClip(GBool needRestore);
  185.  
  186.   // path clipping operators
  187.   void opClip(Object args[]);
  188.   void psClip(Object args[]);
  189.   void opEOClip(Object args[]);
  190.   void psEOClip(Object args[]);
  191.  
  192.   // text object operators
  193.   void opBeginText(Object args[]);
  194.   void psBeginText(Object args[]);
  195.   void opEndText(Object args[]);
  196.   void psEndText(Object args[]);
  197.  
  198.   // text state operators
  199.   void opSetCharSpacing(Object args[]);
  200.   void psSetCharSpacing(Object args[]);
  201.   void opSetFont(Object args[]);
  202.   void psSetFont(Object args[]);
  203.   void opSetTextLeading(Object args[]);
  204.   void psSetTextLeading(Object args[]);
  205.   void opSetTextRender(Object args[]);
  206.   void psSetTextRender(Object args[]);
  207.   void opSetTextRise(Object args[]);
  208.   void psSetTextRise(Object args[]);
  209.   void opSetWordSpacing(Object args[]);
  210.   void psSetWordSpacing(Object args[]);
  211.   void opSetHorizScaling(Object args[]);
  212.   void psSetHorizScaling(Object args[]);
  213.  
  214.   // text positioning operators
  215.   void opTextMove(Object args[]);
  216.   void psTextMove(Object args[]);
  217.   void opTextMoveSet(Object args[]);
  218.   void psTextMoveSet(Object args[]);
  219.   void opSetTextMatrix(Object args[]);
  220.   void psSetTextMatrix(Object args[]);
  221.   void opTextNextLine(Object args[]);
  222.   void psTextNextLine(Object args[]);
  223.  
  224.   // text string operators
  225.   void opShowText(Object args[]);
  226.   void psShowText(Object args[]);
  227.   void opMoveShowText(Object args[]);
  228.   void psMoveShowText(Object args[]);
  229.   void opMoveSetShowText(Object args[]);
  230.   void psMoveSetShowText(Object args[]);
  231.   void opShowSpaceText(Object args[]);
  232.   void psShowSpaceText(Object args[]);
  233.   void doShowText(GString *s);
  234.  
  235.   // XObject operators
  236.   void opXObject(Object args[]);
  237.   void psXObject(Object args[]);
  238.   void doImage(Stream *str);
  239.   void psDoImage(Stream *str);
  240.   void doForm(Stream *str);
  241.   void psDoForm(Stream *str);
  242.  
  243.   // in-line image operators
  244.   void opBeginImage(Object args[]);
  245.   void psBeginImage(Object args[]);
  246.   Stream *buildImageStream();
  247.   void opImageData(Object args[]);
  248.   void psImageData(Object args[]);
  249.   void opEndImage(Object args[]);
  250.   void psEndImage(Object args[]);
  251.  
  252.   // type 3 font operators
  253.   void opSetCharWidth(Object args[]);
  254.   void psSetCharWidth(Object args[]);
  255.   void opSetCacheDevice(Object args[]);
  256.   void psSetCacheDevice(Object args[]);
  257. };
  258.  
  259. #endif
  260.